package com.kefan.reptilemanagement.controller;



import com.baomidou.mybatisplus.extension.api.R;
import com.kefan.reptilemanagement.common.entities.ResultBody;
import com.kefan.reptilemanagement.common.entities.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjj
 * @since 2021-10-17
 */

@RestController
@RequestMapping("/sys/user")
public class SysUserController extends BaseController {
    @Autowired
    private BCryptPasswordEncoder passwordEncoder;


    /**
     * @Author sjj
     * @Description //TODO 注册用户的接口
     * @Date 2021/10/17 2021/10/17
     * @Param [sysUser]
     * @return com.sjj.taskmanagement.common.entities.ResultBody
     */
    @PostMapping("/register")
    public ResultBody register(@Validated @RequestBody SysUser sysUser)
    {
        return ResultBody.success(sysUserService.register(sysUser));
    }

    @DeleteMapping("/delete")
    public ResultBody delete(@RequestParam Integer id)
    {
        return ResultBody.success(sysUserService.delete(id));
    }

    @GetMapping("/list")
    public ResultBody list()
    {
        return ResultBody.success(sysUserService.getUserList());
    }


    @GetMapping("/info")

    public ResultBody getUserInfoById(@RequestParam Integer id)
    {
        return ResultBody.success(sysUserService.getUserInfoById(id));
    }


    @GetMapping("/current")
    public ResultBody getCurrentUserInfo()
    {
        return ResultBody.success(sysUserService.getCurrentUserInfo());
    }


    @PutMapping("/update")

    public ResultBody update(@Validated @RequestBody SysUser sysUser)
    {
        return ResultBody.success(sysUserService.updateById(sysUser));
    }

    @GetMapping("/applicationdata")
    public ResultBody getData()
    {
        return ResultBody.success(sysUserService.getData());
    }
    @GetMapping("/userdata")
    public ResultBody getUserdata()
    {
        return ResultBody.success(sysUserService.getUserCount());
    }
    @GetMapping("/spiderdata")
    public ResultBody getSpiderData()
    {
        return ResultBody.success(sysUserService.getSpiderData());
    }
    @GetMapping("/taskdata")
    public ResultBody getTaskData()
    {
        return ResultBody.success(sysUserService.getTaskData());
    }
    @GetMapping("/timedata")
    public ResultBody getTimeData()
    {
        return ResultBody.success(sysUserService.getTimeData());
    }
}
